#@embedLayout()


#define content()

<form id="vendorFormId" method="post">
    <input type="hidden" name="equVersionId" id="venId" value="#(equVersionId??)">
    <table class="table table-bordered">
        <tr>
            <td style="padding-top:15px;">厂商:</td>
            <td>
                <select id="deviceType" name="deviceType" class="easyui-combobox" data-options="editable: false" style="width: 150px;">
                    #for(vendor : vendorList)
                    <option value="#(vendor.venId)">#(vendor.vendorName)</option>
                    #end
                </select>&nbsp;&nbsp;
            </td>
        </tr>
        <tr>
            <td style="padding-top:15px;">型号:</td>
            <td>
                <select name="deviceName" id="deviceName" class="easyui-combobox" data-options="editable: false">
                    #for(equipment : equipmentList)
                    <option value="#(equipment.equId)">#(equipment.equModel)</option>
                    #end
                </select>

            </td>
        </tr>
        <tr>
            <td>版本:</td>
            <td><input type="text" class="easyui-textbox" id="deviceVersion" name="deviceVersion"
                       data-options="required:true,validType:{length:[1,128]}"
                       value="#(deviceVersion??)">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    function vendor_datagrid_save(opr_type) {
        var url = '';
        if (opr_type === 'add') {
            url = contextRootPath + '/equipment/versionSave';
        } else {
            url = contextRootPath + '/equipment/versionUpdate';
        }

        $('#vendorFormId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                var params = {};
                params.element = vendorDatagridId;
                params.data = data;
                params.dlgId = "vendor_crud_dlg";
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

    $("#deviceType").combobox({
        onSelect:function (selectObj) {
            #if(null == equipmentList)
                getDeviceNameAlias(selectObj.value);
                var dn = document.getElementById("deviceName");
                console.log("dn:" + dn.length);
                if (dn.length > 1) {
                    dn[0].selected = true;
                }
            #end
        }
    });

    function getDeviceNameAlias(venId) {

        $("#deviceName").combobox({
            url: contextRootPath + "/equipment/getEquipments?venId="+venId,
            method: 'get',
            valueField: 'equ_id',
            textField: 'equ_model',
            panelHeight: 'auto',
            width:'150px',
            editable: false,
            onLoadSuccess: function () { //加载完成后,val[0]写死设置选中第一项
                var val = $(this).combobox("getData");
                for (var item in val[0]) {
                    if (item == "equ_id") {
                        $(this).combobox("select", val[0][item]);
                    }
                }
            }
        });
    }

</script>

#end


